package com.ghy.service.impl;

import com.ghy.entity.EbComment;
import com.ghy.entity.EbNews;
import com.ghy.mapper.CommentMapper;
import com.ghy.mapper.NewsMapper;
import com.ghy.service.CommentService;
import com.ghy.service.NewsService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {
    @Autowired
    private CommentMapper commentMapper;

    @Override
    public List<EbComment> listByPage(int page, int pageSize) {
        int from = (page-1)*pageSize;
        return commentMapper.findByPage(from,pageSize);
    }

    @Override
    public Integer getMaxPage(Integer pageSize){
        return commentMapper.getMaxPage(pageSize);
    }

    @Override
    public EbComment selectOne(Integer ecId){
        return commentMapper.selectOne(ecId);
    }
    @Override
    public int updateById(EbComment ebComment){
        return  commentMapper.updateByPrimaryKey(ebComment);
    }

    @Override
    public int remove(int ecId) {
        return commentMapper.remove(ecId);
    }

    @Override
    public int updateNews(EbComment ebComment){
        return commentMapper.updateByPrimaryKey(ebComment);
    }

}
